﻿using System.Data.Entity;
using System.Reflection;
using Abp.EntityFramework;
using Abp.Modules;
using LpbPrj.Client.EntityFramework;

namespace LpbPrj.Client
{
    [DependsOn(typeof(AbpEntityFrameworkModule), typeof(ClientCoreModule))]
    public class ClientDataModule : AbpModule
    {
        public override void PreInitialize()
        {
            Configuration.DefaultNameOrConnectionString = "Default";
        }

        public override void Initialize()
        {
            IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly());
            //Database.SetInitializer<ClientDbContext>(null);

            //数据库设置初始化器自动更新（增加删除字段，不影响现有数据）
            Database.SetInitializer(new MigrateDatabaseToLatestVersion<ClientDbContext, LpbPrj.Client.Migrations.Configuration>());
            new ClientDbContext().Database.Initialize(false);
        }
    }
}
